flutter_chat_ui 2.3.1 copy "flutter_chat_ui: ^2.3.1" to clipboard
flutter_chat_ui: ^2.3.1 copied to clipboard

Free and open-source chat SDK. Build fast, real-time apps and generative AI agents with a high-performance, customizable, cross-platform UI.

example/README.md

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_chat_core/flutter_chat_core.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';

class Basic extends StatefulWidget {
  const Basic({super.key});

  @override
  BasicState createState() => BasicState();
}

class BasicState extends State<Basic> {
  final _chatController = InMemoryChatController();

  @override
  void dispose() {
    _chatController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Chat(
        chatController: _chatController,
        currentUserId: 'user1',
        onMessageSend: (text) {
          _chatController.insertMessage(
            TextMessage(
              // Better to use UUID or similar for the ID - IDs must be unique
              id: '${Random().nextInt(1000) + 1}',
              authorId: 'user1',
              createdAt: DateTime.now().toUtc(),
              text: text,
            ),
          );
        },
        resolveUser: (UserID id) async {
          return User(id: id, name: 'John Doe');
        },
      ),
    );
  }
}

1.48k
likes
160
points
68k
downloads

Publisher

verified publisherflyer.chat

Weekly Downloads

Free and open-source chat SDK. Build fast, real-time apps and generative AI agents with a high-performance, customizable, cross-platform UI.

Homepage
Repository (GitHub)
Contributing

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

cross_cache, diffutil_dart, flutter, flutter_chat_core, provider, scrollview_observer

More

Packages that depend on flutter_chat_ui